package com.itheima.zixi1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MiaoShatest {
    public static void main(String[] args) throws ParseException {
        miaosha("2023-11-11 00:01:18");
        miaosha("2023-11-11 00:10:51");

    }

    private static void miaosha(String time) throws ParseException {
        String start = "2023-11-11 00:00:00";
        String end = "2023-11-11 00:10:00";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startDate =sdf.parse(start);
        Date endDate =sdf.parse(end);
        Long time1 = startDate.getTime();
        Long time2 = endDate.getTime();
        Long time3 = sdf.parse(time).getTime();
        if (time3 >= time1 && time3 <= time2) {
            System.out.println("秒杀成功");
        } else {
            System.out.println("秒杀失败");
        }
    }
}
